import 'package:flutter/material.dart';

void main() {
  runApp(MainPage());
}
class MainPage extends StatefulWidget {
  MainPage({Key? key}) : super(key: key);

  @override
  _MainPageState createState() => _MainPageState();
}

class _MainPageState extends State<MainPage> {
  final ScrollController _controller = ScrollController();//滚动控制器
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
       home:Scaffold(appBar:AppBar(title:Text("滚动列表"),) ,
       body:GridView.builder(
        gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 6,mainAxisSpacing: 10,crossAxisSpacing: 10),
        itemCount: 100,
        itemBuilder: (BuildContext context,int index){
          return Container(
            alignment: Alignment.center,
            // padding: EdgeInsets.all(20),
            //  margin: EdgeInsets.only(bottom: 20),
            //  width:double.infinity,
             color: Colors.blue,
             child:Text("第${index+1}个",
             style:TextStyle(
               fontSize: 20,
               color: Colors.white,
             )),
             height:100,
          );
        },

       )



      //  body:GridView.extent(
      //   maxCrossAxisExtent: 200,
      //   mainAxisSpacing: 10,
      //   crossAxisSpacing: 10,
      //   padding: EdgeInsets.all(10),
      //   children:List.generate(100, (index) {
      //     return Container(
      //       alignment: Alignment.center,
      //       // padding: EdgeInsets.all(20),
      //       //  margin: EdgeInsets.only(bottom: 20),
      //       //  width:double.infinity,
      //        color: Colors.blue,
      //        child:Text("第${index+1}个",
      //        style:TextStyle(
      //          fontSize: 20,
      //          color: Colors.white,
      //        )),
      //        height:100,
      //     );
      //   })
      //  )
       //网格布局-count
      //  body:GridView.count(
      //    crossAxisCount: 3,
      //    mainAxisSpacing: 10,
      //    crossAxisSpacing: 10,
      //    children: List.generate(100, (index) {
      //      return Container(
      //       padding: EdgeInsets.all(20),
      //        margin: EdgeInsets.only(bottom: 20),
      //        width:double.infinity,
      //        height:100,
      //        color: Colors.blue,
      //        child:Text("第${index+1}个",
      //        style:TextStyle(
      //          fontSize: 20,
      //          color: Colors.white,
      //        )),
      //        alignment: Alignment.center,
      //      );
      //    }),
      //  )
    ));  
  }
}